package main

import "fmt"

func allocSlice(min, high int) []int {
	var b = []int{1, 2, 3, 50: 100}
	fmt.Println(b)
	fmt.Println(len(b), cap(b))

	// 此种方式新切片会和原切片共享底层存储， cap值是一样的
	//return b[min:high]

	nb := make([]int, high-min, high-min)
	copy(nb, b[min:high])
	return nb
}

func main() {

	b1 := allocSlice(3, 7)
	fmt.Println(b1)
	fmt.Println(len(b1), cap(b1))

}

/*
[1 2 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100]
51 51
[0 0 0 0]
4 4
*/
